package cn.edu.hitwh.yibao.controller;
import cn.edu.hitwh.yibao.form.DiagnosisProjectForm;
import cn.edu.hitwh.yibao.service.DiagnosisProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

@Controller
public class DiagnosisProjectController {
	@Autowired
	private DiagnosisProjectService diagnosisProjectService;
	
	@GetMapping("/diagnosisProject")
	public String hospital() {
		return "/diagnosisProject/select";
	}
	
	@PostMapping("/diagnosisProject")   
	public String hospitalResult(DiagnosisProjectForm diagnosisProjectForm, Model model) {
		return diagnosisProjectService.select(diagnosisProjectForm, model);
	}
	
	@GetMapping("/diagnosisProject/addInit")
	public String addInit(){
		return "/diagnosisProject/add";
	}
	
	@PostMapping("/diagnosisProject/add")
	public String add(DiagnosisProjectForm diagnosisProjectForm, Model model) {
		return diagnosisProjectService.add(diagnosisProjectForm, model);
	}
	
	@GetMapping("/diagnosisProject/addComplete")
	public String addComplete(Model model) {
		model.addAttribute("addResult", "添加新设施信息成功！");
		return "/diagnosisProject/select";
	}
	
	@GetMapping("/diagnosisProject/updateInit")
	public String updateInit(String diaId, Model model) {
		return diagnosisProjectService.updateInit(diaId,  model);
	}
	
	@PostMapping("/diagnosisProject/update")
	public String update(DiagnosisProjectForm diagnosisProjectForm, Model model) {
		return diagnosisProjectService.update(diagnosisProjectForm, model);
	}
	
	@GetMapping("/diagnosisProject/updateComplete")
	public String updateComplete() {
		return "/diagnosisProject/select";
	}
	
	@GetMapping("/diagnosisProject/delete")
	public String delete(String diaId, Model model) {
		return diagnosisProjectService.delete(diaId,  model);
	}
	
	@GetMapping("/diagnosisProject/deleteComplete")
	public String deleteComplete(Model model) {
		model.addAttribute("deleteResult", "删除设施信息成功！");
		return "/diagnosisProject/select";
	}
	
	@GetMapping("/diagnosisProject/detail")
	public String detail(String diaId, Model model) {
		return diagnosisProjectService.detail(diaId,  model);
	}
	
}
